const express = require('express')
const router = express.Router()
const { sequelize } = require('../common/sequelize')

// route -> get /user
router.get('/', async(req, res, next) => {
  const users = await sequelize.models.user.findAll()
  res.status(200).json(users)
})

// route -> get /user?userId=xxx
router.get('/users/:userId', (req, res, next) => {
  res.json({
    code: 200,
    data: [
      { name: 'user1', favs: 10, userId: req.params.userId }
    ]
  })
})

module.exports = router
